<template>
    <div>
        <el-dialog v-dialogDrag :visible.sync="previewObj.isShow" :close-on-click-modal="false" title="查看${tableComment}" width="50%" @close="cancelDialog">
            <el-form ref="form" :model="form" label-width="60px">
                <#list showProperty as propertyItem>
                    <el-col :xs="24" :lg="12" :xl="8">
                        <el-form-item label="${propertyItem.columnComment}" prop="${propertyItem.property}">
                            <el-input v-model="form.${propertyItem.property}" disabled />
                        </el-form-item>
                    </el-col>
                </#list>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancelDialog">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { get${meta} } from '@/api/${apiUrl}'
export default {
    name: '',
    components: {

    },
    mixins: [

    ],
    props: {
        previewObj: {
            type: Object,
            default: function() {
                return {}
            }
        }
    },
    data() {
        return {
            form: {
                <#list showProperty as propertyItem>
                ${propertyItem.property}:'',
                </#list>
            }
        }
    },
    computed: {

    },
    watch: {

    },
    created() {
        this.$nextTick(() => {
            this.form.id = this.previewObj.${primaryKeyProperty}
            <#list showProperty as propertyItem>
            this.form.${propertyItem.property}= this.previewObj.${propertyItem.property}
            </#list>
        })
    },
    mounted() {
        this.initData()
    },
    methods: {
        // 获取下拉数据
        initData() {
            let params = {
                id: this.previewObj.${primaryKeyProperty}
            }
            get${meta}(params).then(res => {
                if (res.code === 0) {
                    //
                    this.loading = false
                } else {
                    this.$alert(res.message, {
                        type: 'error',
                        confirmButtonText: '确定'
                    })
                    this.loading = false
                }
            }).catch(err => {
                console.log(err)
            })
        },
        // 取消
        cancelDialog() {
            this.$emit('cancelPreviewDialog')
            this.$refs['form'].resetFields()
        }
    }
}
</script>

<style scoped lang="scss">

</style>
